import socket

from dingtalkchatbot.chatbot import DingtalkChatbot


class SendText:
    def __init__(self, webhook):
        # 初始化机器人小丁
        self.xiaoding = DingtalkChatbot(webhook)

    def send_text(self,msg):
        # Text消息@所有人
        self.xiaoding.send_text(msg=msg, is_at_all=False)
        # self.xiaoding.send_link(title='测试',text='测试环境')
        # self.xiaoding.send_link(title='测试',text='测试环境',message_url='https:xxx.com')


if __name__ == '__main__':
    # WebHook地址
    # webhook='https://oapi.dingtalk.com/robot/send?access_token=9e15605640eecb7a104818e492ec0c76fde38c0c4945849371376c0c9ff3a879'
    # send_text=SendText(webhook)
    # send_text.send_text(msg="")

    hostname = socket.gethostname()
    ip_address = socket.gethostbyname(hostname)
    print(f"Hostname: {hostname}")
    print(f"IP Address: {ip_address}")